/*
 * @Descripttion: 
 * @Author: liuYaoYu
 * @Date: 2021-12-14 10:24:11
 * @LastEditors: liuYaoYu
 * @LastEditTime: 2021-12-14 14:26:24
 */
package main
import (
	"fmt"
	"time"
)
func main(){
	// 1-获取当前时间
	now:=time.Now()
	fmt.Printf("当前时间为 %v now type=%T",now,now)
	// 2-通过now可以获取到年月日，时分秒
	fmt.Printf("年=%v\n",now.Year())
	fmt.Printf("月=%v\n",now.Month())
	fmt.Printf("月=%v\n",int(now.Month()))
	fmt.Printf("日=%v\n",now.Day())
	fmt.Printf("时=%v\n",now.Hour())
	fmt.Printf("分=%v\n",now.Minute())
	fmt.Printf("秒=%v\n",now.Second())

	// 第二种方式 使用go语言设计者提出的一种方式
    time := now.Format("2006-01-02 15:04:05")
	fmt.Println(time)
	date :=now.Format("2006-01-02")
	fmt.Println(date)
	timer:=now.Format("15:04:05")
	fmt.Println(timer)
	
}